//===--- Tokens.def - Swift Tokenizer Metaprogramming -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming lexer tokens.
//
//===----------------------------------------------------------------------===//

/// KEYWORD(kw)
///   Expands for every Swift keyword, such as 'if', 'else', etc.
#ifndef KEYWORD
#define KEYWORD(kw)
#endif

/// DECL_KEYWORD(kw)
///   Expands for every Swift keyword that can be used in a declaration.
#ifndef DECL_KEYWORD
#define DECL_KEYWORD(kw) KEYWORD(kw)
#endif

/// STMT_KEYWORD(kw)
///   Expands for every Swift keyword used in statement grammar.
#ifndef STMT_KEYWORD
#define STMT_KEYWORD(kw) KEYWORD(kw)
#endif

/// SIL_KEYWORD(kw)
///   Expands for every SIL keyword. These are only keywords when parsing SIL.
#ifndef SIL_KEYWORD
#define SIL_KEYWORD(kw) KEYWORD(kw)
#endif

/// PUNCTUATOR(name, str)
///   Expands for every Swift punctuator.
///   \param name  The symbolic name of the punctuator, such as
///                'l_paren' or 'arrow'.
///   \param str   A string literal containing the spelling of the punctuator,
///                such as '"("' or '"->"'.
#ifndef PUNCTUATOR
#define PUNCTUATOR(name, str)
#endif

// Keywords that start decls.
DECL_KEYWORD(class)
DECL_KEYWORD(deinit)
DECL_KEYWORD(enum)
DECL_KEYWORD(extension)
DECL_KEYWORD(func)
DECL_KEYWORD(import)
DECL_KEYWORD(init)
DECL_KEYWORD(inout)
DECL_KEYWORD(let)
DECL_KEYWORD(operator)
DECL_KEYWORD(protocol)
DECL_KEYWORD(struct)
DECL_KEYWORD(subscript)
DECL_KEYWORD(typealias)
DECL_KEYWORD(var)

DECL_KEYWORD(internal)
DECL_KEYWORD(private)
DECL_KEYWORD(public)
DECL_KEYWORD(static)

SIL_KEYWORD(undef)
SIL_KEYWORD(sil)
SIL_KEYWORD(sil_stage)
SIL_KEYWORD(sil_vtable)
SIL_KEYWORD(sil_global)
SIL_KEYWORD(sil_witness_table)
SIL_KEYWORD(sil_coverage_map)

// Statement keywords.
STMT_KEYWORD(defer)
STMT_KEYWORD(if)
STMT_KEYWORD(guard)
STMT_KEYWORD(do)
STMT_KEYWORD(repeat)
STMT_KEYWORD(else)
STMT_KEYWORD(for)
STMT_KEYWORD(in)
STMT_KEYWORD(while)
STMT_KEYWORD(return)
STMT_KEYWORD(break)
STMT_KEYWORD(continue)
STMT_KEYWORD(fallthrough)
STMT_KEYWORD(switch)
STMT_KEYWORD(case)
STMT_KEYWORD(default)
STMT_KEYWORD(where)
STMT_KEYWORD(catch)

// Expression keywords.
KEYWORD(as)
KEYWORD(dynamicType)
KEYWORD(false)
KEYWORD(is)
KEYWORD(nil)
KEYWORD(rethrows)
KEYWORD(super)
KEYWORD(self)
KEYWORD(Self)
KEYWORD(throw)
KEYWORD(true)
KEYWORD(try)
KEYWORD(throws)
KEYWORD(__FILE__)
KEYWORD(__LINE__)
KEYWORD(__COLUMN__)
KEYWORD(__FUNCTION__)
KEYWORD(__DSO_HANDLE__)

// Pattern keywords.
KEYWORD(_)

// Punctuators.
PUNCTUATOR(l_paren,       "(")
PUNCTUATOR(r_paren,       ")")
PUNCTUATOR(l_brace,       "{")
PUNCTUATOR(r_brace,       "}")
PUNCTUATOR(l_square,      "[")
PUNCTUATOR(r_square,      "]")

PUNCTUATOR(l_square_lit,  "[#")
PUNCTUATOR(r_square_lit,  "#]")

PUNCTUATOR(period,        ".")
PUNCTUATOR(period_prefix, ".")
PUNCTUATOR(comma,         ",")
PUNCTUATOR(colon,         ":")
PUNCTUATOR(semi,          ";")
PUNCTUATOR(equal,         "=")
PUNCTUATOR(at_sign,       "@")
PUNCTUATOR(pound,         "#")

PUNCTUATOR(amp_prefix,    "&")
PUNCTUATOR(arrow,         "->")

PUNCTUATOR(backtick,      "`")

PUNCTUATOR(exclaim_postfix, "!") // if left-bound

PUNCTUATOR(question_postfix, "?") // if left-bound
PUNCTUATOR(question_infix,"?")    // if not left-bound

PUNCTUATOR(sil_dollar,    "$")    // Only in SIL mode.
PUNCTUATOR(sil_exclamation, "!")    // Only in SIL mode.


#undef KEYWORD
#undef DECL_KEYWORD
#undef STMT_KEYWORD
#undef SIL_KEYWORD
#undef PUNCTUATOR
